#import string
import random

"""
用于生成指定位数的随机密码。这里n填多少，就生成几位，密码为pass1，即'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'中的8位
"""
def gen_pass(n):
    #pass1 = string.digits + string.ascii_letters
    #等同于pass1='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
    pass1 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
    result = ''
    for i in range(n):
        zd = random.choice(pass1)
        result += zd
    return result

passwd = gen_pass(8)
print(passwd)
